# -*- coding:utf-8 -*-
# @Time: 2020/9/23 14:28
# @Author: 周铖鑫
# @Description：绘制3D数据
# @File: 3D-date.py
import  numpy as np
import  matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig=plt.figure(num="我的第一个3D数据")
#3D坐标轴的设置
ax=Axes3D(fig)
X=np.arange(-5,5,0.25)
Y=np.arange(-5,5,0.25)
#转化为坐标矩阵
X,Y=np.meshgrid(X,Y)
R=np.sqrt(X**2+Y**2)
Z=np.sin(R)
#rstride跨度为1
ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap=plt.get_cmap('rainbow'),edgecolor='black')
ax.contourf(X,Y,Z,zdir='z',offset=-2,cmap='rainbow')
ax.set_zlim(-2,2)
plt.show()